package parse

import (
	"gopkg.in/yaml.v3"
	"os"
)

func ParseYml[T any](file string) (*T, error) {
	dataBytes, err := os.ReadFile(file)
	if err != nil {
		return nil, err
	}
	var config T
	err = yaml.Unmarshal(dataBytes, &config)
	if err != nil {
		return nil, err
	}
	return &config, nil
}
func MarshalYml(date any, filePath string) error {
	bytes, err := yaml.Marshal(&date)
	if err != nil {
		return err
	}
	err = os.WriteFile(filePath, bytes, os.ModePerm)
	if err != nil {
		return err
	}
	return nil
}
